using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using static WaterCylinder.Object;
using static WaterCylinder.Resource;

/*
Enemy容器，用于播放生成动画并生成敌怪
*/

public class EnemyContainer : MonoBehaviour
{   
    public static EnemyContainer CreatEnemy(Enemy enemy, Vector2 position){
        GameObject obj = Creat(GetPrefab("DefaultObject/EnemyContainer"), position);
        EnemyContainer contain = obj.GetComponent<EnemyContainer>();
        contain.enemy = enemy;
        return contain;
    }
    public Enemy enemy;
    public UnityEvent CreatEvent;
    public void Create(){
        enemy = Creat(enemy,transform.position);
        CreatEvent?.Invoke();
        Debug.Log("EEE");
        Delete(gameObject);
    }
    private void Start() {
        SpriteRenderer sp = GetComponent<SpriteRenderer>();
        sp.sprite = enemy.showOnCreat;
        Animation animator = GetComponent<Animation>();
        animator.Play();
    }
}
